package com.yoyo.itravel.dao;



import com.yoyo.itravel.bean.Province;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.sql.SQLException;
import java.util.List;

/**
 * @Description 省份表相关操作接口【持久层】
 *
 * @author HZX
 * @date 2020/5/8 23:17
 */
@Repository
public interface IProvinceDao {

	/**
	 * 得到所有的省份信息
	 * 
	 * @return
	 * @throws SQLException
	 */
	@Select("select * from tb_province")
	List<Province> selectAll() throws SQLException;

	/**
	 * 插入省份信息
	 * 
	 * @param province
	 * @return
	 * @throws SQLException
	 */
	@Insert("insert into tb_province(provinceId,provinceName,countryId) values(#{provinceId},#{provinceName},#{countryId})")
	int insert(Province province) throws SQLException;

	/**
	 * 通过城市id得到对应的省份信息
	 * 
	 * @param cityId
	 * @return
	 * @throws SQLException
	 */
	@Select("select * from tb_province where cityId=#{cityId}")
	Province selectByCityId(String cityId) throws SQLException;

	/**
	 * 通过省份名称得到对应的省份信息
	 *
	 * @param provinceName
	 * @return
	 * @throws SQLException
	 */
	@Select("select * from tb_province where provinceName=#{provinceName}")
	Province selectByProvinceName(String provinceName) throws SQLException;

	/**
	 * 得到对应国家的所有省份列表信息
	 *
	 * @param countryId
	 * @return
	 * @throws SQLException
	 */
	@Select("select * from tb_province where countryId=#{countryId}")
	public List<Province> selectByCountryId(String countryId) throws SQLException;

	/**
	 * @Description 通过省份id获得省份对象
	 *
	 * @param provinceId
	 * @return cn.hut.travel.bean.Province
	 */
	@Select("select * from tb_province where provinceId=#{provinceId}")
	Province selectByProvinceId(String provinceId) throws SQLException;
}
